{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $do == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('gongdengfenxiang',array('act' => 'post'))}">添加分享</a></li>
	<li {if $do == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('gongdengfenxiang')}">分享列表</a></li>
</ul>
<style>
#nav-tabs>li.active>a, #nav-tabs>li.active>a:hover, #nav-tabs>li.active>a:focus{ color:#333333; text-decoration:underline; }
</style>
<ul class="nav nav-tabs" id="nav-tabs" style="border:none;">
{loop $glist $glist}
	<li class="active">
    <a style="border:none; background:none;" href="{php echo $this->createWebUrl('gongdengfenxiang',array('display' => 1,'cid' =>$glist['class_id']))}">{$glist['classname']}</a>
    </li>
{/loop}

</ul>
<style>
.table td span{display:inline-block;margin-top:4px;}
.table td input{margin-bottom:0;}
</style>
{if $do == 'display'}
<div class="panel panel-default">
	<div class="table-responsive panel-body">
		<table class="table">
			<thead>
				<tr>
					<th style="width:50px">序号</th>
					<th>分享标题</th>
					<th style="width:200px; text-align:right;">操作</th>
				</tr>
			</thead>
			<tbody>
               {if $list}
				{loop $list $item}
				<tr>
					<td>{$item['id']}</td>
					<td>
						<a href="{php echo $this->createWebUrl('gongdengfenxiang', array('act' => 'post','id' => $item['id']))}" style="color:#333;">
                            {if $item['classname']}<?php echo "["; ?>{$item['classname']}<?php echo "] "; ?>{/if}{$item['title']}</a>
					</td>
					<td style="text-align:right; position:relative;">
               
						<a href="{php echo $this->createWebUrl('gongdengfenxiang', array('act' => 'post','id' => $item['id']))}" title="编辑">编辑</a>&nbsp;-&nbsp;
						<a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" 
                        href="{php echo $this->createWebUrl('gongdengfenxiang', array('act' => 'delete','id' => $item['id']))}" title="删除">删除</a>
					</td>
				</tr>
				{/loop}
            {else}
				<tr>
					<td></td>
					<td>
						<a href="#" style="color:#333;">暂无分享</a>
					</td>
				</tr>            
            {/if}
			</tbody>
		</table>
	</div>
</div>
{$pager}
{elseif $do == 'post'}
<div class="clearfix">
<?php if($edit){$func = 'edit';}else{$func = 'add';} ?>
<form class="form-horizontal form" action="{php echo $this->createWebUrl('gongdeng', array('act' => $func,'id' => $id))}" method="post" enctype="multipart/form-data">
	<div class="panel panel-default">
		<div class="panel-heading">添加分享</div>
		<div class="panel-body">
				<input type="hidden" name="id" value="{$item[id]}">
                
          <!--    <div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">供灯分类</label>
					<div class="col-sm-8 col-xs-12">
						 <select name="classname">
                         <?php if($getclass['class_id']){ ?>
                            <option value={$getclass['class_id']}>{$getclass['classname']}</option>
                         <?php }else{ 
                                    if($item['class_id']){ ?>
                                        <option value={$classfind['class_id']}>{$classfind['classname']}</option>
                              <?php }else{ ?>
                                        <option value="0">请选择供灯分类</option>
                                    <?php } 
                                    foreach($class as $c){ 
                                        if($c['class_id']!=$classfind['class_id']){ ?>
                                            <option value={$c['class_id']}>{$c['classname']}</option>
                                  <?php }
                                    }
                                } ?>
				         </select>
					</div>
				</div>  -->
                
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享标题</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" placeholder="" name="title" value="{$item['title']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享价格</label>
					<div class="col-sm-8 col-xs-12">
						<input type="text" class="form-control" placeholder="" name="prise" value="{$item['title']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享图片</label>
					<div class="col-sm-8 col-xs-12">
						{php echo tpl_form_field_image('thumb', $item['image'])}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
					<div class="col-sm-9 col-xs-12">
						<label>
						（大图片建议尺寸：360像素 * 200像素）
						</label>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">分享内容</label>
					<div class="col-sm-8 col-xs-12">
						{php echo tpl_ueditor('content', $item['content']);}
					</div>
				</div>
		</div>
	</div>

	<div class="form-group">
		<div class="col-sm-12">
			<input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
		</div>
	</div>
</form>
</div>
{/if}
{template 'common/footer'}